1.Field of the Invention
The present invention relates generally to the data processing field, and more particularly, to a computer implemented method, system and computer program product to search for and locate classes in a data processing system having classloaders organized in both a classloader hierarchy and a classloader network.
2.Description of the Related Art
The Java language has traditionally supported classloader objects that are responsible for loading classes. The classloaders are usually organized in a hierarchical tree structure, i.e., in a parent-child relationship. Java Frameworks use classloaders as a way to isolate application classes from runtime classes.
The classloaders use a delegation mechanism to find and load classes and resources across the hierarchy. Most commonly, the delegation pattern is a parent-first delegation pattern which requires a child classloader to delegate a request to load a class to its parent before looking for the requested class within its own scope.
Recently, frameworks such as Open Services Gateway Initiative (OSGi) have been developed which provide additional Java modularity features by incorporating a network of classloaders in their architecture. OSGi framework defines a unit of modularization called “bundle”. A bundle is comprised of Java classes and other resources which together provide function to end users. The OSGi runtime is responsible for loading the bundles. Bundles can hide packages from other bundles, as well as share packages among an exporter bundle and a importer bundle in a well-defined way. The OSGi runtime creates one classloader per bundle, and wires the classloaders together using bundle meta-data that defines class imports and exports. The result is a network of classloaders rather than the hierarchy of classloaders typically found in the Java framework.
Modularity features provided by a framework such as OSGi are beneficial for middleware software systems as they formalize dependencies and relationships between middleware component bundles, and allow for building a more dynamic system. Middleware systems rebasing on OSGi framework would also inherit its network centric (peer-to-peer) classloading model. In reality, however, such middleware systems are likely required to preserve the classloading behavior for their existing customer applications. This is normally achieved by ensuring that application classloaders continue to have visibility to runtime classes just as before when a classloading request is delegated to a parent (runtime) classloader. The difference, however, is that after rebasing on OSGi framework, runtime classloader hierarchy is replaced by a network of bundle classloaders. There is no longer a single parent classloader for the application classloaders.
It would, accordingly, be desirable to provide a mechanism that enables classloaders organized in a classloader hierarchy and classloaders organized in a classloader network to collaborate so as to provide effective classloading while maintaining backward compatibility with existing applications and libraries.